/**
 * Copyright 2021 xpstem.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.xpstem.lelink.enums;

/**
 * EV3 direct command operation code.
 * @author billy zhang
 */
public enum OpCode {

    /**
     * General operations
     */
    ERROR(              0x00 ),
    NOP(                0x01 ),
    PROGRAM_STOP(       0x02 ),
    PROGRAM_START(      0x03 ),
    OBJECT_STOP(        0x04 ),
    OBJECT_START(       0x05 ),
    OBJECT_TRIG(        0x06 ),
    OBJECT_WAIT(        0x07 ),
    RETURN(             0x08 ),
    CALL(               0x09 ),
    OBJECT_END(         0x0A ),
    SLEEP(              0x0B ),
    PROGRAM_INFO(       0x0C ),
    LABEL(              0x0D ),
    PROBE(              0x0E ),
    DO(                 0x0F ),

    SYSTEM(             0x60 ),
    PORT_CNV_OUTPUT(    0x61 ),
    PORT_CNV_INPUT(     0x62 ),
    NOTE_TO_FREQ(       0x63 ),

    INFO(               0x7C ),
    STRING(             0x7D ),
    MEMORY_WRITE(       0X7E),
    MEMORY_READ(        0x7F),

    BP0(                0x88 ),
    BP1(                0x89 ),
    BP2(                0x8A ),
    BP3(                0x8B ),
    PB_SET(             0x8C ),
    RANDOM(             0x8E ),

    /**
     * User interface operations
     */
    UI_FLUSH(           0x80 ),
    UI_READ(            0x81 ),
    UI_WRITE(           0x82 ),
    UI_BUTTON(          0x83 ),
    UI_DRAW(            0x84 ),

    KEEP_ALIVE(         0x90 ),

    /**
     * Sound operations
     */
    SOUND(              0x94 ),
    SOUND_TEST(         0x95 ),
    SOUND_READY(        0x96 ),

    /**
     * Input port operations
     */
    INPUT_DEVICE_LIST(  0x98 ),
    INPUT_DEVICE(       0x99 ),
    INPUT_READ(         0x9A ),
    INPUT_TEST(         0x9B ),
    INPUT_READY(        0x9C ),
    INPUT_READSI(       0x9D ),
    INPUT_READEXT(      0x9E ),
    INPUT_WRITE(        0x9F ),

    /**
     * Output port operations
     */
    OUTPUT_SET_TYPE(    0xA1 ),
    OUTPUT_RESET(       0xA2 ),
    OUTPUT_STOP(        0xA3 ),
    OUTPUT_POWER(       0xA4 ),
    OUTPUT_SPEED(       0xA5 ),
    OUTPUT_START(       0xA6 ),
    OUTPUT_POLARITY(    0xA7 ),
    OUTPUT_READ(        0xA8 ),
    OUTPUT_TEST(        0xA9 ),
    OUTPUT_READY(       0xAA ),
    OUTPUT_STEP_POWER(  0xAC ),
    OUTPUT_TIME_POWER(  0xAD ),
    OUTPUT_STEP_SPEED(  0xAE ),
    OUTPUT_TIME_SPEED(  0xAF ),

    OUTPUT_STEP_SYNC(   0xB0 ),
    OUTPUT_TIME_SYNC(   0xB1 ),
    OUTPUT_CLR_COUNT(   0xB2 ),
    OUTPUT_GET_COUNT(   0xB3 ),
    OUTPUT_PRG_STOP(    0xB4 ),

    /**
     * Communication operations
     */
    COM_READY(          0xD0 ),
    COM_TEST(           0xD1 ),
    COM_GET(            0xD3 ),
    COM_SET(            0xD4 ),
    MAILBOX_OPEN(       0xD8 ),
    MAILBOX_WRITE(      0xD9 ),
    MAILBOX_READ(       0xDA ),
    MAILBOX_TEST(       0xDB ),
    MAILBOX_READY(      0xDC ),
    MAILBOX_CLOSE(      0xDD ),

    COM_READ(           0x91 ),
    COM_WRITE(          0x92 );

    private int value;

    private OpCode(int value) {
        this.value = value;
    }

    public int value() {
        return value;
    }

}
